package com.ry.synContainer;

import java.util.Vector;
import java.util.concurrent.atomic.AtomicInteger;

//同步容器
public class VectorExp {
    //运行这个抛出异常了，java.lang.ArrayIndexOutOfBoundsException: 5000 > 880，说明长度不要超过880
    public static void main(String[] args) {
        Vector v = new Vector();

        new Thread(()->{
            for (int i = 0; i < 5000; i++) {
                v.add(i,i);
            }
        }).start();

        new Thread(()->{
            for (int i = 5000; i < 10000; i++) {
                v.add(i,i);
            }
        }).start();

        System.out.println(v.size());
    }


}
